package org.kosta.android.samples.part1;

import org.kosta.android.samples.R;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class IntentMyForResultActivity extends Activity {
	private TextView tView;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.my_result_activity);
        
        tView = (TextView)findViewById(R.id.return_value);
        
        Button btn = (Button)findViewById(R.id.button);
        btn.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				Intent intent = new Intent(IntentMyForResultActivity.this, OtherForResultActivity.class);
				startActivityForResult(intent,  1);
			}
		});
    }
    
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    	String value="";
    	if(resultCode == RESULT_OK) {
	        switch(requestCode) {
	        case 1:
	                value = data.getStringExtra("returnVal");
	            	tView.setText(value);
	            break;
	        }
    	}
    }
    
}
